const {Sequelize} = require('sequelize');


const db_config = {
    database: 'cors_db',
    username: 'root',
    password: '123456',
    host: '127.0.0.1',
    port: 3306,
};

//2、配置数据库连接对象
const sequelize = new Sequelize(db_config.database, db_config.username, db_config.password, {
    host: db_config.host,
    port: db_config.port,
    dialect: 'mysql',//数据库方言，类型
    timezon: '+08:00',
    logging: false,
    define: {
        timestamps: false //为模型添加 createdAt 和 updatedAt 两个时间戳字段（true or false）
    },
    pool: { //使用连接池连接，默认为true
        max: 50,
        min: 0,
        idle: 30000
    },
})

//3、导出数据库连接的配置对象
module.exports.sequelize = sequelize;
module.exports.db_config = db_config;

